<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\store\controller;

use library\Controller;
use library\tools\Data;
use think\Db;
use app\store\model\Common;
/**
 * 评论列表
 * Class Documentlist
 * @package app\store\controller
 */
class Comment extends Controller
{
    /**
     * 指定数据表
     * @var string
     */
    protected $table = 'StoreStationComment';
    protected $table1 = 'store_station_comment';

    /**
     * 评论列表
     * @auth true
     * @menu true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '评论列表';
        $this->user_list = Db::table("store_member")->field("id,username")->select();
        $this->station_list = Db::table("store_power_station")->field("id,name")->select();

        $query = $this->_query($this->table)->like('comment')->equal("type,user_id,station_id");
        $query->order('id desc')->page();
    }

    /**
     * 数据列表处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function _index_page_filter(&$data)
    {
        foreach ($data as &$vo) {
            $u_id = $vo['user_id'];
            $vo['user'] = Db::table("store_member")->where("id=$u_id")->find();
            $vo['station_name'] = Db::table("store_power_station")->where(["id"=>$vo['station_id']])->value("name");
            $vo['img_arr'] = explode(',',$vo['images']);
            $vo['order_no'] = Db::table("store_yinuo_order")->where(["id"=>$vo['order_id']])->value("order_no");
            //1正常   2故障  3被占用  4停用
            if($vo['type']==1){  $vo['status_r'] = '<span style="color: green;font-weight: bold">好评</span>'; }
            if($vo['type']==2){  $vo['status_r'] = '<span style="color: orangered;font-weight: bold">中评</span>'; }
            if($vo['type']==3){  $vo['status_r'] = '<span style="color: red;font-weight: bold">差评</span>'; }

        }


    }



}
